﻿using System;
using System.Diagnostics;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YJKRevitBase.WinForm;

namespace YJKRevitWndr
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class CmdDoorWinStatistics : YJKCommandAuto
	{
		protected override Result YJKExcute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			try
			{
				if (cmdData.Application.ActiveUIDocument.Document.ActiveView is View3D)
				{
					YJKMessageBox.Show("请切换到平面视图下运行此命令！");
					return Autodesk.Revit.UI.Result.Cancelled;
				}
				Process currentProcess = Process.GetCurrentProcess();
				if (currentProcess != null)
				{
                    WindowHandle owner = new WindowHandle(currentProcess.MainWindowHandle);
					DlgDoorWinStatistics.GetInstance(this.m_uiApp).Show(owner);
				}
				else
				{
					YJKMessageBox.Show("未能得到当前Revit进程！");
				}
			}
			catch (Exception)
			{
			}
			return base.YJKExcute(cmdData, ref message, elements);
		}
	}
}
